<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:t="http://myfaces.apache.org/tomahawk">
<head>
<title>Simulate Transaction</title>
</head>
<body>
<ui:composition template="/template.xhtml">
	<ui:define name="navigation">
		<ui:include src="navigation.xhtml" />
	</ui:define>

	<ui:define name="heading">
		<h:outputText value="Simulate Transaction" />
	</ui:define>

	
	<ui:define name="body">
		<h:form>
			<h:panelGrid columns="2">
				<h:outputText value="Stocks" />
				<h:inputText value="#{alertSearchBean.symbols}" required="true" size="40" />

				<h:outputText value="Investment Amount" />
				<h:inputText value="#{alertSearchBean.investmentAmount}" required="true" size="8" />

				<h:outputText value="Start Date" />
				<t:inputDate type="date" popupCalendar="true" value="#{alertSearchBean.simulationStartDate}" required="true" />

				<h:outputText value="End Date" />
				<t:inputDate type="date" popupCalendar="true" value="#{alertSearchBean.simulationEndDate}" required="true" />

				<h:outputText value="Stop Loss %" />
				<h:inputText value="#{alertSearchBean.simulationSltpPercent}" required="true" size="4">
					<f:convertNumber type="number" />
				</h:inputText>
				
				<h:outputText value="Expected Gain %" />
				<h:inputText value="#{alertSearchBean.simulationExpectedGainPercent}" required="true" size="4">
					<f:convertNumber type="number" />
				</h:inputText>

				<h:outputText value="" />
				<h:commandButton value="Submit" actionListener="#{alertSearchBean.simulateTransactions}" />
			</h:panelGrid>
		</h:form>

		<div id="yahooChartDiv" style="position:fixed;left:22%;top:15%">
			<img id="yahooChart" border="1" onclick="this.style.display='none'" />
		</div>
		
		<h:panelGrid columns="2">
			<h:outputText value="Total Sltp Hits" />
			<h:outputText value="#{alertSearchBean.totalSltpHit}" styleClass="error" />
			<h:outputText value="Total Target Hits" />
			<h:outputText value="#{alertSearchBean.totalTargetHit}" styleClass="success" />
		</h:panelGrid>
		
		<h:dataTable value="#{alertSearchBean.dmNyseSimulation}" var="ns" border="1">
			<h:column>
				<f:facet name="header">
					<h:outputText value="Stock Code" />
				</f:facet>
				<h:outputLink value="http://www.google.com/finance?q=#{ns.nyseBuy.nysePK.symbol}" target="_new" onmouseover="javascript:showChart(document.getElementById('yahooChart'), '#{ns.nyseBuy.nysePK.symbol}')">
					<h:outputText value="#{ns.nyseBuy.nysePK.symbol}" />
				</h:outputLink>
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Bought On" />
				</f:facet>
				<h:outputText styleClass="#{ns.renderClass}" value="#{ns.nyseBuy.nysePK.tradeDate}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Bought Price" />
				</f:facet>
				<h:outputText styleClass="#{ns.renderClass}" value="#{ns.nyseBuy.close}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Stop Loss Hit On" />
				</f:facet>
				<h:outputText styleClass="#{ns.renderClass}" value="#{ns.nyseStopLoss.nysePK.tradeDate}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Stop Loss Low/High" />
				</f:facet>
				<h:outputText styleClass="#{ns.renderClass}" value="#{ns.nyseStopLoss.low} (#{ns.sltp}) #{ns.nyseStopLoss.high}" rendered="#{ns.nyseStopLoss != null}" />
				<h:outputText value="" rendered="#{ns.nyseStopLoss == null}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Target Achieved On" />
				</f:facet>
				<h:outputText styleClass="#{ns.renderClass}" value="#{ns.nyseTarget.nysePK.tradeDate}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Target Low/High" />
				</f:facet>
				<h:outputText styleClass="#{ns.renderClass}" value="#{ns.nyseTarget.low} (#{ns.target}) #{ns.nyseTarget.high}" rendered="#{ns.nyseTarget != null}" />
				<h:outputText value="" rendered="#{ns.nyseTarget == null}" />
			</h:column>


			<h:column>
				<f:facet name="header">
					<h:outputText value="Profit (incl. Brokerage)" />
				</f:facet>
				<h:outputText styleClass="#{ns.renderClass}" value="#{alertSearchBean.simulationProfit}" rendered="#{ns.nyseTarget != null}" />
				<h:outputText value="" rendered="#{ns.nyseTarget == null}" />
			</h:column>

			<h:column>
				<f:facet name="header">
					<h:outputText value="Loss (incl. Brokerage)" />
				</f:facet>
				<h:outputText styleClass="#{ns.renderClass}" value="#{alertSearchBean.simulationLoss}" rendered="#{ns.nyseStopLoss != null}" />
				<h:outputText value="" rendered="#{ns.nyseStopLoss == null}" />
			</h:column>
		</h:dataTable>
	</ui:define>
</ui:composition>
</body>
</html>
